package com.vmove.childtrain.protocol;


import com.vmove.childtrain.utils.ByteUtil;

/**
 * 配置adapter协议
 */
public class AdapterCMD extends AbsProtocol implements Cloneable{

    public AdapterCMD() {
        setDataType(CommandType.COMMAND_SETADAPTER);
    }

    public Object clone() throws CloneNotSupportedException{
        return super.clone();
    }

    byte b0= AdapterMode.SLEEP.getByte();//0进入睡眠 1唤醒

    public AdapterCMD setAdapterMode(byte b){
        this.b0=b;
        return this;
    }

    public AdapterCMD setAdapterMode(int b){
        this.b0= ByteUtil.getBytes1(b)[0];
        return this;
    }

    @Override
    public byte[] getBytes() {
        data = new byte[]{b0};
        return super.getBytes();
    }

    public enum AdapterMode{
        SLEEP((byte)0x00),
        WAKE((byte)0x01);
        byte mode;

        private AdapterMode(byte c){
            this.mode = c;
        }

        public byte getByte(){
            return mode;
        }
    }
}
